package user

import (
	models "HeadLineNews/proto_models/app/account_model"
	"HeadLineNews/utils"
	"github.com/gin-gonic/gin"
)

type Ctx interface {
	ParseParamUserLogin(c *gin.Context) (p *models.RequestUserLogin, err error)
	ParseParamUserRegister(c *gin.Context) (p *models.RequestUserRegister, err error)
}

type ctx struct {
}

func NewCtx() Ctx {
	return &ctx{}
}

// ParseParamUserRegister 解析用户注册参数
func (ctx *ctx) ParseParamUserRegister(c *gin.Context) (p *models.RequestUserRegister, err error) {
	p = new(models.RequestUserRegister)
	err = utils.ShouldBindProtobuf(c, p)
	return
}

// ParseParamUserLogin 解析用户登录参数
func (ctx *ctx) ParseParamUserLogin(c *gin.Context) (p *models.RequestUserLogin, err error) {
	p = new(models.RequestUserLogin)
	err = utils.ShouldBindProtobuf(c, p)
	return
}
